<div class="row">
    <div class="col-sm-20">
        <h1 class="pagetitle" translate lib="web">role</h1>
    </div>
</div>
<style type="text/css">
    .list-group-item:hover {
        color: #337ab7;
        text-shadow: 0 0 1em #337ab7;
        cursor: pointer;
    }

    .listgroupitemselected {
        border: 6px;
        border-color: black;
        background-color: #337ab7;
        color: white;
        cursor: pointer;
    }
</style>

<div ng-show="ctrl.errormessage != ''"" class=" alert alert-danger" role="alert">{{ctrl.errormessage}}</div>
<form ng-submit="ctrl.submit()" class="form-horizontal" role="form" autocomplete="off">

    <div class="form-group">
        <label for="name" class="col-sm-2 control-label" translate lib="web">name</label>
        <div class="col-sm-6">
            <input ng-model="ctrl.model.name" class="form-control input-md" ng-disabled="ctrl.loading==true" />
        </div>
    </div>
    <div class="form-group">
        <label for="name" class="col-sm-2 control-label" translate lib="web">rparole</label>
        <div class="col-sm-6">
            <div class="custom-switch">
                <input type="checkbox" id="rparole" ng-model="ctrl.model.rparole">
                <label for="rparole">rparole</label>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label for="name" class="col-sm-2 control-label" translate lib="web">hide members</label>
        <div class="col-sm-6">
            <div class="custom-switch">
                <input type="checkbox" id="hidemembers" ng-model="ctrl.model.hidemembers">
                <label for="hidemembers">hide members</label>
            </div>
        </div>
    </div>
    <div class="form-group ">
        <label for="add" class="col-sm-2 control-label" translate lib="web">add</label>
        <div class="col-sm-6 input-group">
            <input type="text" name="user" id="user" ng-model="ctrl.searchtext" ng-keyup="ctrl.setkey($event)"
                autocomplete="off" class="form-control" ng-model-options="{ debounce: 500 }"
                ng-change="ctrl.handlefilter()" ng-keypress="ctrl.restrictInput($event)" />
            <!-- <select ng-model='ctrl.addthis' class="form-control"
                ng-options='item._id as (item.name + " " + item.username) for item in ctrl.users'></select> -->
            <button ng-click="ctrl.AddMember(ctrl.addthis)" type="button"
                ng-disabled="ctrl.loading==true || ctrl.searchSelectedItem==null" class="btn btn-success " translate
                lib="web">add</button>
        </div>
    </div>
    <div>
        <div class="col-sm-2"></div>
        <div class="col-sm-6">
            <ul class="list-group">
                <li class="list-group-item" ng-repeat="item in ctrl.searchFilteredList"
                    ng-click="ctrl.fillTextbox(item.name)"
                    ng-class="{listgroupitemselected: ctrl.searchSelectedItem._id==item._id}">
                    ({{item._type}}) {{item.name}} <span ng-show="item.name != item.username">{{" " +
                        item.username}}</span>
                </li>
            </ul>
        </div>
    </div>
    <div class="form-inline" ng-repeat="m in ctrl.model.members">
        <label class="col-sm-1 control-label" translate lib="web">member</label>
        <div class="col-sm-3">
            {{ m.name }}
        </div>
        <div class="col-sm-2">
            <button ng-click=" ctrl.RemoveMember(m)" type="button" ng-disabled="ctrl.loading==true"
                class="btn btn-success" translate lib="web">remove</button>
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" ng-disabled="ctrl.loading==true" class="btn btn-success" translate
                lib="web">save</button>
        </div>
    </div>


</form>